home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / vopts / vopts.h < prev   
C/C++ Source or Header  |  1993-12-18  |  11KB  |  260 lines

  1. #define GadToolsBase_DECLARED
  2. #define AslBase_DECLARED
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <dos/dos.h>
  8. #include <dos/dosextens.h>
  9. #include <libraries/gadtools.h>
  10. #include <workbench/startup.h>
  11. #include <workbench/workbench.h>
  12. #include <exec/memory.h>
  13. #include <proto/exec.h>
  14. #include <proto/graphics.h>
  15. #include <proto/intuition.h>
  16. #include <proto/gadtools.h>
  17. #include <intuition/intuitionbase.h>
  18. #include <proto/asl.h>
  19. #include <proto/dos.h>
  20. #include <proto/wb.h>
  21. #include <proto/icon.h>
  22. #include "renderinfo.h"
  23. #include "defaultfonts.h"
  24. #undef GLOBAL
  25.  
  26. typedef struct WBStartup    WBStartup;
  27. typedef struct DiskObject   DiskObject;
  28. typedef struct IntuiText IntuiText;
  29.  
  30. #define ALT_CONFIG_FILE "DCC_Config:VOpts.Config"
  31. #define CONFIG_FILE "DCC:Config/VOpts.config"
  32.  
  33. extern struct Library *GadToolsBase;
  34. extern struct Library *AslBase;
  35. extern struct Library *ArpBase;
  36.  
  37. struct XMenu {
  38.    struct Menu      menu;
  39.    APTR             userdata;
  40.    struct Image     image;
  41. };
  42.  
  43. struct XItem {
  44.    struct MenuItem  item;
  45.    APTR             userdata;
  46.    struct IntuiText itext;
  47. };
  48.  
  49. #define MAX_LIST  3        /* Number of items to display in a list        */
  50. #define MAX_MENU   64      /* Largest number of menu items to allow       */
  51. #define MAX_TITLE  63      /* Longest titlebar string                     */
  52.  
  53. #define MENU_END  NM_END   /* Indicates the last item in a menu           */
  54. #define MENU_MENU NM_TITLE /* Indicates a menu entry (with subitems)      */
  55. #define MENU_ITEM NM_ITEM  /* Indicates a menu item                       */
  56. #define MENU_SUB  NM_SUB   /* Indicates a submenu item                    */
  57. #define MENU_BAR  4        /* Used for a bar between menu items           */
  58.  
  59. #define MAX_STRING 64      /* Largest allowable string                    */
  60. #define MAX_FILENAME 255   /* Longest possible file name                  */
  61.  
  62. #define MODE_OUT 0
  63. #define MODE_IN  1
  64.  
  65. #define MARGIN_TOP      4
  66. #define MARGIN_BOTTOM   3
  67. #define MARGIN_MID      4
  68.  
  69. #define MARGIN_LEFT     8
  70. #define MARGIN_RIGHT    8
  71. #define MARGIN_SEP     20
  72.  
  73. #define VBAR            2         /* Pixel width of a vertical BAR        */
  74. #define DVBAR           (2*VBAR)  /* Pixel width of two vertical BARs     */
  75. #define HBAR            1         /* Pixel height of a horizontal BAR     */
  76. #define DHBAR           (2*HBAR)  /* Pixel height of two Horizontal BARs  */
  77.  
  78. #define CYC_ICON_WIDTH 24
  79.  
  80. #define CHECK_WIDTH    26
  81. #define CHECK_HEIGHT   11
  82.  
  83. #define BUTTON_WIDTH   80
  84.  
  85. #define CLASS_STRING 1
  86. #define CLASS_CYCLE  2
  87. #define CLASS_CHECK  3
  88. #define CLASS_GROUP  4
  89. #define CLASS_LIST   5
  90. #define CLASS_LIST1  6     /* Not really a gadget type                     */
  91. #define CLASS_LIST2  7     /* Not really a gadget type                     */
  92. #define CLASS_BUTTON 8
  93. #define CLASS_ENTRY  9
  94. #define CLASS_ADD   10     /* Not really a gadget type                     */
  95. #define CLASS_DEL   11     /* Not really a gadget type                     */
  96. #define CLASS_UP    12     /* Not really a gadget type                     */
  97. #define CLASS_DOWN  13     /* Not really a gadget type                     */
  98. #define CLASS_PROP  14     /* Not really a gadget type                     */
  99. #define CLASS_REFRESH 15   /* Fake a refresh event                         */
  100.  
  101. #define BUTTON_SAVE   0    /* Save button on main window                   */
  102. #define BUTTON_USE    1    /* Use button on main window                    */
  103. #define BUTTON_CANCEL 2    /* Cancel button on main window                 */
  104. #define BUTTON_NEW    3    /* NEW button on any list object                */
  105. #define BUTTON_DEL    4    /* DEL button on any list object                */
  106. #define MAX_BUTTON 6
  107. /* these buttons aren't in the main buttongadget array                     */
  108. #define BUTTON_FRSAVE 6    /* Default "file requester" Save button         */
  109. #define BUTTON_FRCNCL 7    /* Default "file requester" Cancel button       */
  110.  
  111.  
  112. #define TEXT_NOMEM      0       /* Not enough memory                    */
  113. #define TEXT_BADOPT     1       /* Invalid command line option          */
  114. #define TEXT_BADFILE    2       /* Unable to open the file              */
  115. #define TEXT_BADCMD     3       /* Invalid command                      */
  116. #define TEXT_EXTRAPRG   4       /* More than one #pragma in a file      */
  117. #define TEXT_SAVEOK     5       /* Confirm OK to save options to file   */
  118. #define TEXT_BIGOPTS    6       /* options string too long to write     */
  119. #define TEXT_FILEREQ    7       /* string gadget file requester         */
  120. #define TEXT_GLOBOPTS   8       /* Editing global options               */
  121. #define TEXT_FILEOPTS   9       /* Editing options for file             */
  122. #define TEXT_OVWRITEOK 10       /* Operation will overwrite existing file */
  123. #define TEXT_NORENAME  11       /* Can't rename existing file           */
  124. #define TEXT_NOREAD    12       /* Unable to read existing file         */
  125. #define TEXT_NOWRITE   13       /* Error writing, unable to update      */
  126. #define TEXT_NOOVWRITE 14       /* Can't overwrite existing file        */
  127. #define TEXT_CANCEL    15       /* Cancel button for requesters         */
  128. #define TEXT_OK        16       /* OK button for requesters             */
  129. #define MAX_TEXT      18
  130.  
  131. #define FILE_ENV       1
  132. #define FILE_OPTIONS   2
  133. #define FILE_C         3
  134. #define FILE_DMAKEFILE 4
  135.  
  136. struct G_OBJECT {
  137.    struct G_OBJECT *next;  /* Next object in the list                      */
  138.                            /* Note you must cast to use based on the class */
  139.    struct G_OBJECT *prev;  /* Previous object in the list.                 */
  140.    char             class; /* Class of the object                          */
  141.    char             state; /* State (meaning is class based)               */
  142.    char            *title; /* Title associated with the object.            */
  143.    struct Gadget   *gadget;/* Intuition Gadget representing object         */
  144. };
  145.  
  146. struct G_STRING {
  147.    struct G_OBJECT  base;
  148.    char            *option;
  149.    char             buf[MAX_STRING];
  150. };
  151.  
  152. struct G_VALUE {
  153.    struct G_VALUE  *next;   /* Next cycle in the list                   */
  154.    char            *title;  /* Title to print for this value in a cycle */
  155.    char            *option; /* The option for this choice in the cycle  */
  156.    struct G_STRING *string; /* For those cycles supporting a string     */
  157. };
  158.  
  159. struct G_CYCLE {
  160.    struct G_OBJECT  base;   /* Base object information                  */
  161.    struct G_VALUE  *values; /* List of all possible values              */
  162.    struct G_VALUE  *curval; /* Current value                            */
  163. };
  164.  
  165. struct G_CHECK {
  166.    struct G_OBJECT  base;   /* Base object information                  */
  167.    char            *option0;/* Non-selected option value                */
  168.    char            *option1;/* Selected option value                    */
  169. };
  170.  
  171. struct G_ENTRY {
  172.    struct G_OBJECT  base;   /* Base object information                  */
  173.    char             buf[MAX_STRING]; /* Value for the current entry     */
  174. };
  175.  
  176. struct G_LIST {
  177.    struct G_OBJECT  base;   /* Base object information                  */
  178.                             /* State shows which item is selected       */
  179.    char            *option; /* Option value for all entries             */
  180.    struct G_ENTRY  *first;  /* First option in the list                 */
  181.    struct G_ENTRY  *top;    /* Top option being displayed               */
  182.    char              string;/* Any string gadget for the entry          */
  183.    char              maxent;/* Number of entries in the list            */
  184.    struct Gadget   *delgad; /* The delete gadget                        */
  185.    struct Gadget   *slider; /* The proportional gadget                  */
  186.    struct Gadget   *strgad[MAX_LIST];  /* String gadgets for the list   */
  187.    struct Gadget   *btngad[MAX_LIST];  /* Button gadgets for the list   */
  188.    struct Border   *sborder;/* Border for any active strings            */
  189. };
  190.  
  191. struct G_GROUP {
  192.    struct G_OBJECT  base;
  193.    struct G_OBJECT *objects;/* List of all objects in the current group */
  194.    int              local;  /* 0 global, 1 exclude for env:             */
  195. };
  196.  
  197. struct GADLIST {
  198.    struct Gadget *gadgets;
  199.    int            count;
  200. };
  201.  
  202. /**********************************************************/
  203. struct GLOBAL {
  204.    struct RenderInfo  ri;
  205.    struct Window     *window;
  206.    FILE              *fp;
  207.    int                line;
  208.    int                state;
  209.    int                done;
  210.    int                width;
  211.    int                height;
  212.    int                iheight;
  213.    int                eheight;  /* Height of an entry in a list */
  214.    int                maxsize;
  215.    int                stxtwid;  /* min width for string or list text entry */
  216.    int                lgadwid;  /* width of list gaget slider and buttons  */
  217.    int                boxx, boxy, boxw, boxh;
  218.    struct NewMenu     menuitem[MAX_MENU+1];
  219.    char               title[MAX_TITLE+1];
  220.    char               wtitle[MAX_TITLE+1];
  221.    struct G_OBJECT    button[MAX_BUTTON];
  222.    struct G_OBJECT    *objects;            /* Base object list */
  223.    struct G_GROUP     *groups;             /* Group list       */
  224.    struct G_GROUP     *curgroup;
  225.    struct GADLIST     *gadlist;
  226.    struct GADLIST     *grpgadlist;
  227.    struct RastPort    *rp;
  228.    struct Border      *cycborder[2];
  229.    struct Border      *checkborder[2];
  230.    struct Border       arrowborder[2];
  231.    struct Menu        *menu;
  232.    struct GADLIST     *frgadlist;  /* stuff for default "file requester" */
  233.    struct G_STRING    frstring;
  234.    struct G_OBJECT    frbutton[2];
  235.    int                cycsize[3];
  236.    int                titsize[3];
  237.    char               filename[MAX_FILENAME+1];
  238.    int                filetype;
  239.    struct FileRequester *freq;
  240.    char               *text[MAX_TEXT];
  241.    int                listextra;
  242.    int                fileop; /* is default file request 0:read or 1:write? */
  243.    int                nameoffile; /* 0 unless global.filename was read in */
  244.    char               defbuf[MAX_STRING]; /* default buffer for list str gads */
  245. };
  246.  
  247. extern struct GLOBAL global;
  248.  
  249. /***************************************************************************/
  250. /* Stuff to make ARP work.                                                 */
  251. /***************************************************************************/
  252. #pragma libcall ArpBase ArpFileRequest 126 801
  253. #pragma libcall ArpBase ArpAllocFreq   294 000
  254.  
  255. extern struct FileRequester *ArpAllocFreq(void);
  256. extern char *ArpFileRequest(struct FileRequester *);
  257.  
  258. #define Prototype extern
  259. #include "VOpts-protos.h"
  260.